import gymnasium as gym
from stable_baselines3 import PPO
import warnings

# 主函数
def main():
    env = gym.make('Humanoid-v5', ctrl_cost_weight=0.1, render_mode="human")

    # 加载模型
    model = PPO.load("/home/sh/catkin_ws/src/ymbot_e_control/policy/ppo_humanoid", device='cpu')

    # 验证策略，渲染画面
    obs = env.reset()[0]  # 只获取观察值
    for _ in range(1000):
        action, _states = model.predict(obs)
        obs, rewards, dones, truncated, info = env.step(action)
        env.render()  # 渲染画面
        if dones or truncated:
            obs = env.reset()[0]  # 重新开始 

    env.close()

if __name__ == '__main__':
    main()
